package com.woniuxy02;

import com.woniuxy01.Student;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author 作者
 * @create 2025-09-24 16:38
 */
public class Test01 {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        QueryRunner qr = new QueryRunner();
        String sql="select * from stu where sid=?";
        Student stu = qr.query(JdbcUtil.getConnection(), sql, new BeanHandler<>(Student.class),1);
        System.out.println(stu);
    }

    private static void test02() throws SQLException, ClassNotFoundException {
        QueryRunner qr = new QueryRunner();
        String sql="select * from stu";
        List<Student> stus = qr.query(JdbcUtil.getConnection(), sql, new BeanListHandler<>(Student.class));
        System.out.println(stus);
    }

    private static void test01() throws SQLException, ClassNotFoundException {
        //queryrunner执行增删改
        QueryRunner qr = new QueryRunner();
        String sql="insert into stu values(?,?,?,?)";
        qr.update(JdbcUtil.getConnection(), sql,7,"777","777",17);
    }
}
